//
//  PaidTableViewCell.m
//  HTP
//
//  Created by 王鑫 on 15/11/2.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "PayTableViewCell.h"

@interface PayTableViewCell ()

@property (nonatomic, retain) UILabel *infoLabel;

@property (nonatomic, retain) UIImageView *icoImage;

@property (nonatomic, retain) UILabel *nameLabel;

@property (nonatomic, retain) UILabel *priceLabel;

@property (nonatomic, retain) UILabel *timeLabel;

@property (nonatomic, retain) UILabel *orderNum;

@property (nonatomic, retain) UILabel *moneyLabel;

@property (nonatomic, retain) UIImageView *payImage;

@property (nonatomic, retain) UIImageView *line1;

@property (nonatomic, retain) UIImageView *line2;

@end

@implementation PayTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self _initUI];
    }
    return self;
}

- (void)_initUI {
    _infoLabel = [[UILabel alloc] init];
    _infoLabel.font = [UIFont systemFontOfSize:17.0f];
    [self.contentView addSubview:_infoLabel];
    
    _icoImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_icoImage];
    
    _nameLabel = [[UILabel alloc] init];
    _nameLabel.font = [UIFont systemFontOfSize:15.0f];
    [self.contentView addSubview:_nameLabel];
    
    _priceLabel = [[UILabel alloc] init];
    _priceLabel.font = [UIFont systemFontOfSize:15.0f];
    [self.contentView addSubview:_priceLabel];
    
    _timeLabel = [[UILabel alloc] init];
    _timeLabel.font = [UIFont systemFontOfSize:15.0f];
    [self.contentView addSubview:_timeLabel];
    
    _orderNum = [[UILabel alloc] init];
    _orderNum.font = [UIFont systemFontOfSize:12.0f];
    [self.contentView addSubview:_orderNum];
    
    _moneyLabel = [[UILabel alloc] init];
    _moneyLabel.font = [UIFont systemFontOfSize:18.0f];
    _moneyLabel.textColor = [UIColor orangeColor];
    [self.contentView addSubview:_moneyLabel];
    
    _payImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_payImage];
    
    _line1 = [[UIImageView alloc] init];
    [_line1 setAlpha:0.6];
    [self.contentView addSubview:_line1];
    
    _line2 = [[UIImageView alloc] init];
    [_line2 setAlpha:0.6];
    [self.contentView addSubview:_line2];
}

- (void)layoutSubviews:(NSString *)flag{
    
    [_icoImage setFrame:CGRectMake(10, 44, 110, 80)];
    
    [_infoLabel setFrame:CGRectMake(10, 5, 200, 20)];
    
    [_nameLabel setFrame:CGRectMake(130, 49, 80, 25)];
    
    [_priceLabel setFrame:CGRectMake(130, 74, 80, 25)];
    
    [_timeLabel setFrame:CGRectMake(130, 99, 120, 25)];
    
    [_orderNum setFrame:CGRectMake(10, 150, 100, 25)];
    
    if ([flag isEqualToString:@"true"]) {
        [_moneyLabel setFrame:CGRectMake(ScreenWidth - 100, 150, 90, 25)];
    }else
        [_moneyLabel setFrame:CGRectMake(ScreenWidth - 140, 150, 90, 25)];

    
    [_payImage setFrame:CGRectMake(ScreenWidth - 70, 149, 60, 27)];
    
    [_line1 setFrame:CGRectMake(0, 30, ScreenWidth, 1)];
    
    [_line2 setFrame:CGRectMake(0, 144, ScreenWidth, 2)];
}

- (void)setCellData:(id)cellData {
    
    NSDictionary *dic = (NSDictionary *)cellData;
    
    _infoLabel.text = dic[@"orderName"];
    
    _nameLabel.text = [NSString stringWithFormat:@"姓名:%@",dic[@"name"]];
    
    _priceLabel.text = [NSString stringWithFormat:@"价格:%@",dic[@"price"]];
    
    _timeLabel.text = [NSString stringWithFormat:@"时间:%@",dic[@"time"]];
    
    _orderNum.text = [NSString stringWithFormat:@"订单号:%@",dic[@"orderNum"]];
    
    if ([dic[@"pay"] isEqualToString:@"false"]) {
        _payImage.image = [UIImage imageNamed:@"支付按钮"];
    }
    _moneyLabel.text = [NSString stringWithFormat:@"%@",dic[@"money"]];
    
    _icoImage.backgroundColor = [UIColor redColor];
    
    
    _line1.image = [UIImage imageNamed:@"横线"];
    _line2.image = [UIImage imageNamed:@"横线"];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
